#include "fxcc/yml/Serializer.h"
#include "fxcc/core/graph/common/AnimationController.h"

using namespace fxcc::yml;
using namespace fxcc::graph::common;

template<>
void Serializer::Encode<ParamValue>(YAML::Node& node, const ParamValue& inst)
{
	SetVariableEnum<ParamType>(node, "type", inst.type);

	switch (inst.type)
	{
	case ParamType::Float:
		SetVariable<float>(node, "f", inst.f);
		break;
	case ParamType::Bool:
		SetVariable<bool>(node, "b", inst.b);
		break;
	case ParamType::Int:
		SetVariable<int>(node, "i", inst.i);
		break;
	default:
		break;
	}
}

template<>
bool Serializer::Decode<ParamValue>(const YAML::Node& node, ParamValue& inst)
{
	GetVariableEnum<ParamType>(node, "type", inst.type);

	switch (inst.type)
	{
	case ParamType::Float:
		GetVariable<float>(node, "f", inst.f);
		break;
	case ParamType::Bool:
		GetVariable<bool>(node, "b", inst.b);
		break;
	case ParamType::Int:
		GetVariable<int>(node, "i", inst.i);
		break;
	default:
		break;
	}
	return true;
}

template<>
void Serializer::Encode<XParams>(YAML::Node& node, const XParams& inst)
{
	SetMapVariable<ParamValue>(node, "values", inst.values);
}

template<>
bool Serializer::Decode<XParams>(const YAML::Node& node, XParams& inst)
{
	GetMapVariable<ParamValue>(node, "values", inst.values);
	return true;
}
